package net.htjs.juc.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class ThreadExcerise {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            try {
                log.info("洗水壶");
                TimeUnit.SECONDS.sleep(1);
                log.info("烧开水");
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "老王");
        Thread t2 = new Thread(() ->{
            try {
                log.info("洗茶壶");
                TimeUnit.SECONDS.sleep(1);
                log.info("洗茶杯");
                TimeUnit.SECONDS.sleep(1);
                log.info("拿茶叶");
                TimeUnit.SECONDS.sleep(1);
                t1.join();
                log.info("泡茶");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "小王");
        t1.start();
        t2.start();
    }

}
